package com.mx.kn.cstf2.dao.impl;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import kn.cstf2.cop.Bean.TransitionsBeanCop;
import kn.cstf2.cop.Sql.CopSql;
import kn.cstf2.transition.Bean.TransitionBean;

import com.mx.kn.cstf2.dao.CopDao;


@Repository
@Component("copDao")
public class CopDaoImpl implements CopDao{

	private JdbcTemplate jdbcStksf2;
	private JdbcTemplate jdbcCustomerSalesToolKit;

	@Autowired
	public void setDataSourceStkfsf2(@Qualifier("dataSourceStkfsf2") DataSource DataSourceStkfsf2) {
		this.jdbcStksf2 = new JdbcTemplate(DataSourceStkfsf2);
	}
	
	@Autowired
	public void setDataSourceCustomerSalesToolKit(@Qualifier("dataSourceCustomerSalesToolKit")
			DataSource dataSourceCustomerSalesToolKit) {
		this.jdbcCustomerSalesToolKit = new JdbcTemplate(dataSourceCustomerSalesToolKit);
		
	}
	
	@Override
	public void updateReportingTransition(TransitionBean transition) throws  SQLException{
		String sql =  CopSql.UPDATE_REPORTING_TRANSITIONS;
		int rows = jdbcStksf2
				.update(sql, new Object[] {transition.getReporting(), transition.getReportingdate(), transition.getId()});
	}
	
	@Override
	 public void updateScopeOfServiceTransition(TransitionBean transition) throws SQLException{
		 String sql = CopSql.UPDATE_SCOPEOFSERVICE_TRANSITIONS;
		 int rows = jdbcStksf2
					.update(sql, new Object[] {transition.getScopeofservice(), transition.getScopeofservicedate(), transition.getId()});
	 }

}
